package org.dzq.designmode.flyweight;

/**
 * @ClassName: Test
 * @Package: org.dzq.designmode.flyweight
 * @author: 越
 * @date: 2023/6/18 21:46
 * @Description: 同一个name共享同一个对象
 */
public class Test {
    public static void main(String[] args) {
        IFlyweight flyweight1 = FlyweightFactory.getFlyweightByName("123");
        IFlyweight flyweight2 = FlyweightFactory.getFlyweightByName("123");
        IFlyweight flyweight3 = FlyweightFactory.getFlyweightByName("234");
        flyweight1.operation();
        flyweight2.operation();
        flyweight3.operation();
        ConcreteFlyweight flyweight4 = (ConcreteFlyweight)flyweight2;
        flyweight4.setName("567");
        flyweight4.operation();
        flyweight1.operation();
        flyweight2.operation();
    }
}
